<%@page import="board.BoardVo"%>
<%@page import="java.util.Vector"%>
<%@page import="board.Board"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>list.jsp</title>
<style>


#tot{
position: relative;
width:100%;

}

#brdTitle1,#brdTitle2,#brdTitle3,#brdTitle4{
display: inline-block;

font-weight:bold;
text-align: center;
height: 25px;
padding-top: 7px;
background-color: #E6E6E6;}
#brdTitle1{width:50px;}
#brdTitle2{width:300px;}
#brdTitle3{width:100px;}
#brdTitle4{width:150px;}

#brdSub1,#brdSub2,#brdSub3,#brdSub4{
display: inline-block;
border: 3px solid #ffffff;
height: 25px;
padding-top: 7px;
white-space: nowrap;
text-overflow:ellipsis;
overflow:hidden;

}
#brdSub1{width:50px;text-align:center;}
#brdSub2{width:300px;}
#brdSub3{width:100px;}
#brdSub4{width:150px;}
#st_hr{
margin-top:0px;
position: relative;
width:600px;
height:5px;
}
</style>
<script>
function Insert(){
	location.href='index2.jsp?inc_content=./board/register.jsp';
	
}

function getId(id){return document.getElementById(id);}

function init1(){
	document.getElementById('btFind').onkeyup = function(ev) {
		if (ev.keyCode == 13)
		brdfind_form.action = 'index2.jsp?inc_content=./board/list.jsp&nowPage='+ 1;
	};
	
		if(getId("btFind")!=null){
		getId("btFind").onclick=function(){
			brdfind_form.action="index2.jsp?inc_content=./board/list.jsp&nowPage=" + 1;
			brdfind_form.submit();
		};
	}

	
}
function view(s){
	location.href='index2.jsp?inc_content=./board/view.jsp&serial=' + s;
}



function goPage(page){
	brdfind_form.nowPage.value = page;
	brdfind_form.action="index2.jsp?inc_content=./board/list.jsp";
	brdfind_form.submit();
	
}
</script>
</head>
<body>
<jsp:useBean id="boardVo" class="board.BoardVo"/>
<jsp:setProperty property="*" name="boardVo"/>

<%

//검색어 세션처리
if(request.getMethod().equals("POST")){
	session.setAttribute("find", boardVo.getFind());
	
}else{
	if(session.getAttribute("find")!=null){
		boardVo.setFind((String)session.getAttribute("find"));
	}
}

//페이지 정보유지
if(request.getParameter("nowPage")==null){
	if(session.getAttribute("nowPage")!=null)
	boardVo.setNowPage((Integer)session.getAttribute("nowPage"));	
}else{
	session.setAttribute("nowPage", boardVo.getNowPage());
}


	String part=(String)session.getAttribute("part");
	boardVo.setPart(part);
	
	Board board = new Board();
	board.setVo(boardVo);
	board.setNowPage(boardVo.getNowPage());
	Vector<BoardVo> v= board.list();
%>


<h1>✦게시판 목록(<%=part %>)</h1>
<hr/>
<div id='tot'>
<!-- 검색 & 글쓰기 버튼-->
<div id='btnGroup1'>
	<form name='brdfind_form' action='' method="post">
		<input type='button' id='btInsert' name='btInsert' onclick='Insert()' value='글쓰기'>
		<input type='search' id='find' name='find' value='<%=boardVo.getFind()%>'>
		<input type='submit' id='btFind' name='btFind' value='검색'>
		<input type='hidden' name='nowPage' value="<%=board.getNowPage() %>">
	</form>
	</div>
	
<%-- <div>
<li>전체건수:<%=board.getTotSize() %>
<li>전체 페이지수:<%=board.getTotPage() %>
<li>전체 블럭수: <%=board.getBlockSize() %>
<li>현재 블럭:<%=board.getNowBlock() %>
<li>시작페이지:<%=board.getStartPage() %>
<li>끝 페이지:<%=board.getEndPage() %>
<li>시작번호:<%=board.getStartNo() %>
<li>끝번호:<%=board.getEndNo() %>
</div> --%>


<!-- 게시판 목록-->
<p/>
<div id='brdTitle'>
	<div id='brdTitle1'>순번</div>
	<div id='brdTitle2'>제목 </div>
	<div id='brdTitle3'>작성자</div>
	<div id='brdTitle4'>작성일</div>
</div>

<!-- 게시판 글 -->
<% for(int i=0; i<v.size(); i++){
	BoardVo vo= v.get(i);
	%>

<div id='brdSub'>
<%if (vo.getSerial() == vo.getGrp()){ %>
	<div id='brdSub1'><%=vo.getSerial() %></div>
	<div id='brdSub2'>
	<a href='#' onclick='view(<%=vo.getSerial()%>)'>[<%=vo.getPart() %>]<%=vo.getSubject()%>(<%=vo.getHit() %>)</a></div>
<%}else{ %>
	<div id='brdSub1'></div>
	<div id='brdSub2'>
	<a href='#' onclick='view(<%=vo.getSerial()%>)'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└<%=vo.getSubject()%>(<%=vo.getHit() %>)</a></div>
<%} %>
	<div id='brdSub3'><%=vo.getMid() %></div>
	<div id='brdSub4'><%=vo.getMdate() %></div>
	
	<div id='st_hr'><hr size=2 noshade></div>
</div>

<%} %>

<div> <!-- 페이지 분리 영역 -->
	<%if(board.getNowBlock()> 1 ){ %>
	<input type="button" value="맨첨" onclick='goPage(1)'>
	<input type="button" value="이전" onclick='goPage(<%=board.getStartPage()-1 %>)'>
	<%} %>
	[
	<%for(int p=board.getStartPage();p<=board.getEndPage();p++){ %>
	<input type="button" value='<%=p %>' onclick='goPage(<%=p %>)'>
	<% }%>
	]
	<%if(board.getNowBlock()<board.getTotBlock()){ %>
	<input type="button" value="다음" onclick='goPage(<%=board.getEndPage()+1 %>)'>
	<input type="button" value="맨끝" onclick='goPage(<%=board.getTotPage() %>)'>
	<%} %>
</div>




</div>

<script>init1();</script>

</body>
</html>